//
//  LXDRadioCollectionViewCell.m
//  BLDMusics
//
//  Created by lxd on 16/3/18.
//  Copyright © 2016年 李晓丹. All rights reserved.
//

#import "LXDRadioCollectionViewCell.h"


@interface LXDRadioCollectionViewCell ()

/**图片*/
@property (nonatomic, retain) UIImageView *songImage;

/**歌曲类型*/
@property (nonatomic, retain) UILabel *titleLabel;

/**听歌量*/
@property (nonatomic, retain) UILabel *countLabel;


/**灰色背景*/
@property (nonatomic, retain) UIView *grayView;

@end

@implementation LXDRadioCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createControl];
    }
    return self;
}

- (void)createControl {
    
    self.songImage = [[UIImageView alloc]init];
    [self.contentView addSubview:_songImage];
    
    self.grayView = [[UIView alloc] init];
    [self.songImage addSubview:_grayView];
    
    self.titleLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_titleLabel];
    
    self.countLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_countLabel];

    self.playButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:_playButton];
}


- (void)layoutSubviews {
    [super layoutSubviews];
    
    _songImage.frame = self.bounds;
    
    _grayView.frame = _songImage.frame;
    _grayView.backgroundColor = [UIColor blackColor];
    _grayView.alpha = 0.1;
//    _grayView.userInteractionEnabled = NO;
    
    _titleLabel.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height / 5);
    _titleLabel.center = _songImage.center;
    _titleLabel.textColor = [UIColor whiteColor];
    _titleLabel.font = [UIFont boldSystemFontOfSize:19];
    _titleLabel.textAlignment = NSTextAlignmentCenter;
    _titleLabel.userInteractionEnabled = NO;
    
    _countLabel.frame = CGRectMake(0, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 5, self.bounds.size.width, 20);
    _countLabel.textColor = [UIColor whiteColor];
    _countLabel.font = [UIFont boldSystemFontOfSize:13];
     _countLabel.textAlignment = NSTextAlignmentCenter;
    _countLabel.userInteractionEnabled = NO;
    
    _playButton.frame = CGRectMake(self.bounds.size.width - 35, self.bounds.size.height - 35, 25, 25);
    _playButton.userInteractionEnabled = NO;
    
}


- (void)setModel:(LXDRadioModel *)model {
    _model = model;
    [self assignControls];
}


- (void)assignControls {

    [_songImage sd_setImageWithURL:[NSURL URLWithString:self.model.large_pic_url] placeholderImage:PLACEHOLDER];
 
    _titleLabel.text = self.model.tag_name;
    _countLabel.text = self.model.quantity;
}

@end
